package com.ruicar.afs.cloud.finance.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruicar.afs.cloud.finance.common.entity.FinanceVirtualAccount;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

/**
 * <p>Description: </p>
 *
 * @author ZC.GUO
 * @version 1.0
 * @date create on 2020-07-02 10:18
 */
public interface FinanceVirtualAccountMapper extends BaseMapper<FinanceVirtualAccount> {

    /**
     * 收款金额分配时更新客户虚拟账户
     * @author ZC.GUO
     * @param var1 分配金额
     * @param var2 id
     * @param var3 乐观锁
     * @return
     */
    @Update({"update finance_virtual_account set used_amt = used_amt + #{amount},un_used_amt  = un_used_amt - #{amount}, revision = revision + 1 where id=#{id} and revision=#{revision}"})
    int updateWhenDistribution(@Param("amount") BigDecimal var1,@Param("id") Long var2,@Param("revision") Long var3);

}
